package View
{
	import GameItem.Tank.Tank;
	
	import Model.Constants;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	public class GameBattle extends Sprite
	{
		private static var instance:GameBattle;
		private static var m_stage:Stage;
		public static function get gameStage():Stage
		{
			return m_stage;
		}
		
		private var m_background:Sprite;
		public function GameBattle()
		{
			super();
			
			addEventListener(Event.ADDED_TO_STAGE,init);
		}
		public static function getInstance():GameBattle
		{
			if(null==instance)
			{
				instance=new GameBattle();
			}
			return instance;
		}
		private function init(evt:Event):void
		{
			m_stage=stage;
			createBackground();
			createTank();
		}
		public function get battleSizeX():int
		{
			return Constants.GRID_NUM_X;
		}
		public function get battleSizeY():int
		{
			return Constants.GRID_NUM_Y;
		}
		private function createBackground():void
		{
			m_background=new Sprite();
			m_background.graphics.lineStyle(3,Constants.COLOR_LINE);
			m_background.graphics.beginFill(Constants.COLOR_BATTLE_BACKGROUND);
			m_background.graphics.drawRect(0,0,Constants.BATTLE_WIDTH,Constants.BATTLE_HEIGHT);
			m_background.graphics.endFill();
			addChildAt(m_background,0);
		}
		private function createTank():void
		{
			var tank:Tank=new Tank();
			addChild(tank.displayObject);
		}
	}
}